********************************************************************************
********************************************************************************
** Robustness analysis 10
** Heterogeneity in regard to same-gender schools
********************************************************************************
********************************************************************************

** Load data
use "$dataraw_path\data_ftna_publication.dta", clear


gen same_gender_school = (male_school==1 | female_school==1)

eststo rob10_1: areg gpa_ftna_core_sd private##same_gender_school female ///
	uncommon_name peers_score_core_sd peers_fail_share peers_as_share ///
	gpa_psle_other_sd, ///
	cl(school_id) a(group_id)

eststo rob10_2: areg gpa_ftna_core_sd private##male_school female ///
	uncommon_name peers_score_core_sd peers_fail_share peers_as_share ///
	gpa_psle_other_sd, ///
	cl(school_id) a(group_id)

eststo rob10_3: areg gpa_ftna_core_sd private##female_school female ///
	uncommon_name peers_score_core_sd peers_fail_share peers_as_share ///
	gpa_psle_other_sd, ///
	cl(school_id) a(group_id)

eststo rob10_4: areg gpa_ftna_core_sd private##male_school ///
	private##female_school female uncommon_name peers_score_core_sd ///
	peers_fail_share peers_as_share gpa_psle_other_sd, ///
	cl(school_id) a(group_id)

drop same_gender_school

* Output
esttab rob10_* using "$out_path\tableb6.tex", replace se ///
stats(N r2, fmt(%12.3gc) labels("\(N\)" "\(R^2\)")) compress nomtitles ///
starlevels("" 0.01) substitute(\_ _) b(3) ///
/*KEEP*/k(1.private 1.same_gender_school 1.private#1.same_gender_school ///
1.male_school 1.private#1.male_school 1.female_school ///
1.private#1.female_school) ///
/*ORDER*/o(1.private 1.same_gender_school 1.private#1.same_gender_school ///
1.male_school 1.private#1.male_school 1.female_school ///
1.private#1.female_school) ///
/*LABELS*/varl(1.private "\$Private_s$" ///
1.same_gender_school "\$\textit{Same gender school}_s$" ///
1.private#1.same_gender_school "\$Private_s \times \textit{Same gender school}_s$" ///
1.male_school "\$\textit{Boys school}_s$" ///
1.private#1.male_school "\$Private_s \times \textit{Boys school}_s$" ///
1.female_school "\$\textit{Girls school}_s$" ///
1.private#1.female_school "\$Private_s \times \textit{Girls school}_s$")
